<template>
	<view :class="[primarySize()]">
		<view class="container plr30 bg-white">
			<navigator hover-class="none" url="/pages/public/privacy_business" class="set_item flex-box">
				<view class="fs30 col3 flex-grow-1">屏蔽公司</view>
				<image src="https://admin.mosizp.cn/static/public/arrow_right1.png" mode="aspectFit" class="ico22 ml20"></image>
			</navigator>
			<view class="set_item flex-box">
				<view class="fs30 col3 flex-grow-1">隐藏简历</view>
				<switch :checked="resume_status!=1" @change="bindResumeStatusChange" color='var(--primary)' />
			</view>
			<view class="set_item flex-box">
				<view class="fs30 col3 flex-grow-1">隐藏手机号码</view>
				<switch :checked="hide_mobile==1" @change="bindHideMobileChange" color='var(--primary)' />
			</view>
			<view class="set_item flex-box">
				<view class="fs30 col3 flex-grow-1">隐藏教育经历</view>
				<switch :checked="hide_education==1" @change="bindHideEducationChange" color='var(--primary)' />
			</view>
		</view>
	</view>
</template>

<script>
	const app = getApp();
	export default {
		data() {
			return {
				
				hide_mobile: 0,
				hide_education: 0,
				resume_status: 0,
				ret: {
					data: ''
				}
			}
		},
		onReady() {
			uni.setNavigationBarColor({
				frontColor: '#ffffff',
				backgroundColor: this.primaryColor()
			})
		},
		onLoad(options) {
			this.$core.get({
				'url': 'xilujob.user/privacy_setting',
				success: ret => {
					
					this.ret.data = ret.data;
					this.hide_mobile=ret.data.hide_mobile;
					this.hide_education=ret.data.hide_education;
					this.resume_status=ret.data.resume_status;
					this.$forceUpdate()
				}
			});
		},
		methods: {
			bindResumeStatusChange(event) {
				this.resume_status= event.detail.value ? 0 : 1
				
				this.$core.post({
					url: 'xilujob.user/privacy_setting',
					data: {
						resume_status: this.resume_status
					},
					loading: false,
					success: ret => {
						this.resume_status=ret.data.resume_status;
						this.$forceUpdate()
					},
					fail: ret => {
						this.resume_status=this.resume_status == 1 ? 1 : 0
						this.$forceUpdate()
					}
				});
			},
			bindHideMobileChange(event) {
				this.hide_mobile= event.detail.value ? 1 : 0
				this.$core.post({
					url: 'xilujob.user/privacy_setting',
					data: {
						hide_mobile: this.hide_mobile
					},
					loading: false,
					success: ret => {
						this.hide_mobile= ret.data.hide_mobile
						this.$forceUpdate()
					},
					fail: ret => {
						this.hide_mobile=this.hide_mobile == 1 ? 0 : 1
						this.$forceUpdate()
					}
				});
			},
			bindHideEducationChange(event) {
				this.hide_education= event.detail.value ? 1 : 0;
				this.$core.post({
					url: 'xilujob.user/privacy_setting',
					data: {
						hide_education: this.hide_education
					},
					loading: false,
					success: ret => {
						this.hide_education= ret.data.hide_education;
						this.$forceUpdate()
					},
					fail: ret => {
						this.hide_education= this.hide_education == 1 ? 0 : 1
						this.$forceUpdate()
					}
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
	.set_item {
		line-height: 109rpx;
		border-bottom: 1rpx solid #F3F3F3
	}
	.ico22{
		width: 22rpx;
		height: 22rpx;
	}
</style>